import utils from '@/utils/index'
export const state = (e) => ({
   
    screenWidth:1920,
    // lang:[
    //     { name_cn: "英文", name: "English", code: "en", file: "en.js" },
    //     {
    //       name_cn: "中文",
    //       name: "简体中文",
    //       code: "zh",
    //       file: "zh.js",
    //     },
    //     {
    //      name_cn: "越南",
    //      name: "Tiếng Việt",
    //      code: "vi",
    //      file: "vi.js",
    //    },
    // ],
    them:['dark','white'],
    token:utils.getToken()|| '',
    isLogin:utils.getToken()|| false,
    theme:localStorage.getItem('theme')||"light",
})

export const mutations = {
    SET_screenWidth(state, data) {
        state.screenWidth = data
    },
    set_loginStatus(state, data) {
        utils.setToken(data)
        state.isLogin = !!data
        state.token = data

    },    
    set_theme(state, data) {
     
        window.localStorage.setItem('theme',data)
    },
}
export const actions = {
    setTheme({commit},theme) {
 
     if (theme) {
            theme = theme == "dark" ? "light" : "dark"
    }
     theme= theme ||localStorage.getItem('theme')||'white'
      window.document.documentElement.setAttribute('theme', theme);
        commit('set_theme',theme)
    },
    setLoginFn({commit},indo) {

           commit('set_loginStatus',indo)
       }
 
}

